﻿// ----------------------------------------------------------------
// Description : 实体类,该文件由MyGeneration生成
// Author      : 
// Create date : 2009-12-26
// ----------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace ITOMMS.Entity
{
	/// <summary>
	///	tbProductSale Entity
	///	tbProductSale Entity产品销售表
	/// </summary>
	[Serializable]
	public class tbProductSaleEntity : BaseEntity<tbProductSaleEntity,int>
	{
		
		#region 私有成员			
		
		private int _ID; 
		private int _CustomerID; 
		private string _服务项目; 
		private string _产品名称; 
		private string _编号; 
		private string _供货商; 
		private string _品牌; 
		private string _类别; 
		private string _型号; 
		private string _单位; 
		private string _规格; 
		private int? _数量; 
		private decimal? _单价; 
		private decimal? _总价; 
		private string _具体详情; 
		private string _负责人; 
		private DateTime? _日期时间; 
		private DateTime? _CreateDate; 
		private int? _CreateBy; 
		private DateTime? _ModifyDate; 
		private int? _ModifyBy; 
		private string _SaleType; 
		private string _AttachmentPath; 
		private string _跟进信息1; 
		private string _跟进信息2; 
		private string _跟进信息3; 
		private string _跟进信息4; 
		private string _跟进信息5; 
		private int _SEQNO;
		#endregion


		
		#region 默认( 空 ) 构造函数
		/// <summary>
		/// 默认构造函数
		/// </summary>
		public tbProductSaleEntity()
		{
			_ID = 0; 
			_CustomerID = 0; 
			_服务项目 = String.Empty; 
			_产品名称 = String.Empty; 
			_编号 = String.Empty; 
			_供货商 = String.Empty; 
			_品牌 = String.Empty; 
			_类别 = String.Empty; 
			_型号 = String.Empty; 
			_单位 = String.Empty; 
			_规格 = String.Empty; 
			_数量 =  null; 
			_单价 =  null; 
			_总价 =  null; 
			_具体详情 = String.Empty; 
			_负责人 = String.Empty; 
			_日期时间 =  null; 
			_CreateDate =  null; 
			_CreateBy =  null; 
			_ModifyDate =  null; 
			_ModifyBy =  null; 
			_SaleType = String.Empty; 
			_AttachmentPath = String.Empty; 
			_跟进信息1 = String.Empty; 
			_跟进信息2 = String.Empty; 
			_跟进信息3 = String.Empty; 
			_跟进信息4 = String.Empty; 
			_跟进信息5 = String.Empty; 
			_SEQNO = 0;
		}
		#endregion
		
		#region 属性值校验
		
		/// <summary>
		/// 属性值校验
		/// </summary>
		public bool CheckValues()
		{
			bool bResult = true;
			string strError = "";
		
			if ( _ID ==  0)
			{
				bResult = false;
				strError += "\r\n 非空值不能为: "+_ID;
			}
			
			if ( _CustomerID ==  0)
			{
				bResult = false;
				strError += "\r\n 非空值不能为: "+_CustomerID;
			}
			
			if( !bResult )
					throw new ArgumentOutOfRangeException(strError);
			return bResult;
			
		}
		
		#endregion
		
		
		
	
		#region Required Fields Only Constructor
		
		/// <summary>
		/// required (not null) fields only constructor
		/// </summary>
		public tbProductSaleEntity(
		int para_ID, int para_CustomerID		)
		: this()
		{
					_ID = para_ID;
			_CustomerID = para_CustomerID;
			_服务项目 = String.Empty;
			_产品名称 = String.Empty;
			_编号 = String.Empty;
			_供货商 = String.Empty;
			_品牌 = String.Empty;
			_类别 = String.Empty;
			_型号 = String.Empty;
			_单位 = String.Empty;
			_规格 = String.Empty;
			_数量 = null;
			_单价 = null;
			_总价 = null;
			_具体详情 = String.Empty;
			_负责人 = String.Empty;
			_日期时间 = null;
			_CreateDate = null;
			_CreateBy = null;
			_ModifyDate = null;
			_ModifyBy = null;
			_SaleType = String.Empty;
			_AttachmentPath = String.Empty;
			_跟进信息1 = String.Empty;
			_跟进信息2 = String.Empty;
			_跟进信息3 = String.Empty;
			_跟进信息4 = String.Empty;
			_跟进信息5 = String.Empty;
		}
		#endregion 

		
		#region 公有属性
			
			/// <summary>
			/// 行号，顺序号。系统默认的属性,对这个属性不要作操作.属性值在架构中已经处理
			/// </summary>
			public virtual int SEQNO
			{
				get { return _SEQNO; }
				set { _SEQNO = value; }
			}
		
			
		/// <summary>
		/// IDID
		/// </summary>		
		public virtual int ID
		{
			get { return _ID; }
			set { _ID = value; }
		}
			
		/// <summary>
		/// CustomerIDCustomerID
		/// </summary>		
		public virtual int CustomerID
		{
			get { return _CustomerID; }
			set { _CustomerID = value; }
		}
			
		/// <summary>
		/// 服务项目服务项目
		/// </summary>		
		public virtual string 服务项目
		{
			get { return _服务项目; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 服务项目", value, value.ToString());
				
				_服务项目 = value;
			}
		}
			
		/// <summary>
		/// 产品名称产品名称
		/// </summary>		
		public virtual string 产品名称
		{
			get { return _产品名称; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 100)
						throw new ArgumentOutOfRangeException("Invalid value for 产品名称", value, value.ToString());
				
				_产品名称 = value;
			}
		}
			
		/// <summary>
		/// 编号编号
		/// </summary>		
		public virtual string 编号
		{
			get { return _编号; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 编号", value, value.ToString());
				
				_编号 = value;
			}
		}
			
		/// <summary>
		/// 供货商供货商
		/// </summary>		
		public virtual string 供货商
		{
			get { return _供货商; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 供货商", value, value.ToString());
				
				_供货商 = value;
			}
		}
			
		/// <summary>
		/// 品牌品牌
		/// </summary>		
		public virtual string 品牌
		{
			get { return _品牌; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 品牌", value, value.ToString());
				
				_品牌 = value;
			}
		}
			
		/// <summary>
		/// 类别类别
		/// </summary>		
		public virtual string 类别
		{
			get { return _类别; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 类别", value, value.ToString());
				
				_类别 = value;
			}
		}
			
		/// <summary>
		/// 型号型号
		/// </summary>		
		public virtual string 型号
		{
			get { return _型号; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 型号", value, value.ToString());
				
				_型号 = value;
			}
		}
			
		/// <summary>
		/// 单位单位
		/// </summary>		
		public virtual string 单位
		{
			get { return _单位; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 单位", value, value.ToString());
				
				_单位 = value;
			}
		}
			
		/// <summary>
		/// 规格规格
		/// </summary>		
		public virtual string 规格
		{
			get { return _规格; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 规格", value, value.ToString());
				
				_规格 = value;
			}
		}
			
		/// <summary>
		/// 数量数量
		/// </summary>		
		public virtual int? 数量
		{
			get { return _数量; }
			set { _数量 = value; }
		}
			
		/// <summary>
		/// 单价单价
		/// </summary>		
		public virtual decimal? 单价
		{
			get { return _单价; }
			set { _单价 = value; }
		}
			
		/// <summary>
		/// 总价总价
		/// </summary>		
		public virtual decimal? 总价
		{
			get { return _总价; }
			set { _总价 = value; }
		}
			
		/// <summary>
		/// 具体详情具体详情
		/// </summary>		
		public virtual string 具体详情
		{
			get { return _具体详情; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 100)
						throw new ArgumentOutOfRangeException("Invalid value for 具体详情", value, value.ToString());
				
				_具体详情 = value;
			}
		}
			
		/// <summary>
		/// 负责人负责人
		/// </summary>		
		public virtual string 负责人
		{
			get { return _负责人; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 负责人", value, value.ToString());
				
				_负责人 = value;
			}
		}
			
		/// <summary>
		/// 日期时间日期时间
		/// </summary>		
		public virtual DateTime? 日期时间
		{
			get { return _日期时间; }
			set { _日期时间 = value; }
		}
			
		/// <summary>
		/// CreateDate创建时间
		/// </summary>		
		public virtual DateTime? CreateDate
		{
			get { return _CreateDate; }
			set { _CreateDate = value; }
		}
			
		/// <summary>
		/// CreateBy创建人
		/// </summary>		
		public virtual int? CreateBy
		{
			get { return _CreateBy; }
			set { _CreateBy = value; }
		}
			
		/// <summary>
		/// ModifyDate修改时间
		/// </summary>		
		public virtual DateTime? ModifyDate
		{
			get { return _ModifyDate; }
			set { _ModifyDate = value; }
		}
			
		/// <summary>
		/// ModifyBy修改人
		/// </summary>		
		public virtual int? ModifyBy
		{
			get { return _ModifyBy; }
			set { _ModifyBy = value; }
		}
			
		/// <summary>
		/// SaleTypeSaleType
		/// </summary>		
		public virtual string SaleType
		{
			get { return _SaleType; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 10)
						throw new ArgumentOutOfRangeException("Invalid value for SaleType", value, value.ToString());
				
				_SaleType = value;
			}
		}
			
		/// <summary>
		/// AttachmentPath附件路径
		/// </summary>		
		public virtual string AttachmentPath
		{
			get { return _AttachmentPath; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for AttachmentPath", value, value.ToString());
				
				_AttachmentPath = value;
			}
		}
			
		/// <summary>
		/// 跟进信息1
		/// </summary>		
		public virtual string 跟进信息1
		{
			get { return _跟进信息1; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 100)
						throw new ArgumentOutOfRangeException("Invalid value for 跟进信息1", value, value.ToString());
				
				_跟进信息1 = value;
			}
		}
			
		/// <summary>
		/// 跟进信息2
		/// </summary>		
		public virtual string 跟进信息2
		{
			get { return _跟进信息2; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 100)
						throw new ArgumentOutOfRangeException("Invalid value for 跟进信息2", value, value.ToString());
				
				_跟进信息2 = value;
			}
		}
			
		/// <summary>
		/// 跟进信息3
		/// </summary>		
		public virtual string 跟进信息3
		{
			get { return _跟进信息3; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 100)
						throw new ArgumentOutOfRangeException("Invalid value for 跟进信息3", value, value.ToString());
				
				_跟进信息3 = value;
			}
		}
			
		/// <summary>
		/// 跟进信息4
		/// </summary>		
		public virtual string 跟进信息4
		{
			get { return _跟进信息4; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 100)
						throw new ArgumentOutOfRangeException("Invalid value for 跟进信息4", value, value.ToString());
				
				_跟进信息4 = value;
			}
		}
			
		/// <summary>
		/// 跟进信息5
		/// </summary>		
		public virtual string 跟进信息5
		{
			get { return _跟进信息5; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 100)
						throw new ArgumentOutOfRangeException("Invalid value for 跟进信息5", value, value.ToString());
				
				_跟进信息5 = value;
			}
		}
			


		#endregion 	
		
		
        #region DAO操作
		
		
		/// <summary>
        /// 获取所有实体的列表
        /// </summary>
        /// <returns></returns>
        public override List<tbProductSaleEntity> GetAll()
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("select [ID],[CustomerID],[服务项目],[产品名称],[编号],[供货商],[品牌],[类别],[型号],[单位],[规格],[数量],[单价],[总价],[具体详情],[负责人],[日期时间],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[SaleType],[AttachmentPath],[跟进信息1],[跟进信息2],[跟进信息3],[跟进信息4],[跟进信息5] from [tb_ProductSale] ");
	
            List<tbProductSaleEntity> list = new List<tbProductSaleEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
				int seq = 0;
                while (dataReader.Read())
                {	seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		/// <summary>
        /// 获取所有实体的列表总行数
        /// </summary>
        /// <returns></returns>
        public override int GetTotalRecords()
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("  select count([ID])  from [tb_ProductSale] ");
	
            Database db = GetDatabase();
            return (int)db.ExecuteScalar(CommandType.Text, strSql.ToString());
        }
		
		/// <summary>
        /// 获取所有实体的列表总行数
        /// </summary>
        /// <returns></returns>
        public override int GetTotalRecords(string sqlCondition)
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("  select count([ID])  from [tb_ProductSale]  ");
	
			 if (sqlCondition.Trim() != "")
            {
                strSql.Append(" where " + sqlCondition);
            }
            Database db = GetDatabase();
            return (int)db.ExecuteScalar(CommandType.Text, strSql.ToString());
        }	
		
		
		/// <summary>
        /// 按条件查询,得到一页的对应的结果列表
        /// </summary>
        /// <param name="strWhere">条件</param>
		/// <param name="PageSize">每页大小</param>
		/// <param name="CurrentPageIndex">当前页码</param>
        /// <returns></returns>
		 public override List<tbProductSaleEntity> GetAllByQuery(string strWhere, int PageSize, int CurrentPageIndex)
        {
            StringBuilder strSql = new StringBuilder();
            if (strWhere.Contains("order".ToLower()))
            {
                throw new Exception("分页查询的sql条件中不能包括排序子句，请调用重载方法实现有条件的排序筛选");
            }
		 
			strSql.Append("select top ").Append(PageSize).Append("  [ID],[CustomerID],[服务项目],[产品名称],[编号],[供货商],[品牌],[类别],[型号],[单位],[规格],[数量],[单价],[总价],[具体详情],[负责人],[日期时间],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[SaleType],[AttachmentPath],[跟进信息1],[跟进信息2],[跟进信息3],[跟进信息4],[跟进信息5] from [tb_ProductSale] where ");

			 if (strWhere.Trim() != "")
            {
                strSql.Append("  " + strWhere + " and ");
            }
			  strSql.Append(" ID not in ( ");
			 strSql.Append(" select top ").Append(PageSize*(CurrentPageIndex-1)).Append("  [ID] from [tb_ProductSale] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere );
            }
			strSql.Append(" ) " );

            List<tbProductSaleEntity> list = new List<tbProductSaleEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
			   int seq = PageSize * (CurrentPageIndex - 1);
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader, seq));
                }
            }
            return list;
        }
		
		
			/// <summary>
        /// 按条件查询,得到一页的对应的结果列表
        /// </summary>
        /// <param name="strWhere">条件</param>
		/// <param name="PageSize">每页大小</param>
		/// <param name="CurrentPageIndex">当前页码</param>
		/// <param name="strSort">ex:order by id desc</param>
        /// <returns></returns>
		 public override List<tbProductSaleEntity> GetAllByQuery(string strWhere,string strSort, int PageSize, int CurrentPageIndex)
        {
            StringBuilder strSql = new StringBuilder();
            if (strWhere.Contains("order".ToLower()))
            {
                throw new Exception("分页查询的sql条件中不能包括排序子句，请调用重载方法实现有条件的排序筛选");
            }
		 
			strSql.Append("select top ").Append(PageSize).Append("  [ID],[CustomerID],[服务项目],[产品名称],[编号],[供货商],[品牌],[类别],[型号],[单位],[规格],[数量],[单价],[总价],[具体详情],[负责人],[日期时间],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[SaleType],[AttachmentPath],[跟进信息1],[跟进信息2],[跟进信息3],[跟进信息4],[跟进信息5] from [tb_ProductSale] where ");

			 if (strWhere.Trim() != "")
            {
                strSql.Append("  " + strWhere + " and ");
            }
			  strSql.Append(" ID not in ( ");
			 strSql.Append(" select top ").Append(PageSize*(CurrentPageIndex-1)).Append("  [ID] from [tb_ProductSale] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere+" " ).Append(strSort);
            }
			strSql.Append(" ) " ).Append(strSort);

            List<tbProductSaleEntity> list = new List<tbProductSaleEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
				int seq = PageSize * (CurrentPageIndex - 1);
                while (dataReader.Read())
                {	
					seq++;
                    list.Add(ReaderBind(dataReader, seq));
                }
            }
            return list;
        }
		
		
		/// <summary>
        /// 按条件查询,得到对应的结果列表
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public override List<tbProductSaleEntity> GetAllByQuery(string strWhere)
        {
			strWhere = SQLInjectionFilter(strWhere);
            StringBuilder strSql = new StringBuilder();
			strSql.Append("select [ID],[CustomerID],[服务项目],[产品名称],[编号],[供货商],[品牌],[类别],[型号],[单位],[规格],[数量],[单价],[总价],[具体详情],[负责人],[日期时间],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[SaleType],[AttachmentPath],[跟进信息1],[跟进信息2],[跟进信息3],[跟进信息4],[跟进信息5] from tb_ProductSale ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List<tbProductSaleEntity> list = new List<tbProductSaleEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            { 
				int seq = 0;
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		
		/// <summary>
        /// 按条件查询,得到对应的结果列表
        /// </summary>
        /// <param name="strWhere"></param>
		/// <param name="parameters">sql条件中的参数</param>
        /// <returns></returns>
        public override List<tbProductSaleEntity> GetAllByQuery(string strWhere, List<IDataParameter> parameters)
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("select [ID],[CustomerID],[服务项目],[产品名称],[编号],[供货商],[品牌],[类别],[型号],[单位],[规格],[数量],[单价],[总价],[具体详情],[负责人],[日期时间],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[SaleType],[AttachmentPath],[跟进信息1],[跟进信息2],[跟进信息3],[跟进信息4],[跟进信息5] from [tb_ProductSale] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List<tbProductSaleEntity> list = new List<tbProductSaleEntity>();
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            foreach (IDataParameter sp in parameters)
            {
                db.AddInParameter(dbCommand, sp.ParameterName, sp.DbType, sp.Value);
            }

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
				int seq =0 ;
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		

		
		
		/// <summary>
        /// 获取按条件查询以后的结果列表的前指定rowNumber行记录
        /// </summary>
        /// <param name="strWhere">不带where关键字的SQL条件语句</param>
        /// <param name="rowNumber"></param>
        /// <returns></returns>
        public override List<tbProductSaleEntity> GetAllByQuery(string strWhere, List<IDataParameter> parameters, int rowNumber)
        {

            StringBuilder strSql = new StringBuilder();
			strSql.Append("select top ").Append(rowNumber).Append("  [ID],[CustomerID],[服务项目],[产品名称],[编号],[供货商],[品牌],[类别],[型号],[单位],[规格],[数量],[单价],[总价],[具体详情],[负责人],[日期时间],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[SaleType],[AttachmentPath],[跟进信息1],[跟进信息2],[跟进信息3],[跟进信息4],[跟进信息5] from [tb_ProductSale] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List<tbProductSaleEntity> list = new List<tbProductSaleEntity>();
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            foreach (IDataParameter sp in parameters)
            {
                db.AddInParameter(dbCommand, sp.ParameterName, sp.DbType, sp.Value);
            }

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {	
				int seq = 0;
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		/// <summary>
        /// 获取按条件查询以后的结果列表的前指定rowNumber行记录
        /// </summary>
        /// <param name="strWhere">不带where关键字的SQL条件语句: AND AA=@AA</param>
        /// <param name="rowNumber"></param>
        /// <returns></returns>
        public override List<tbProductSaleEntity> GetAllByQuery(string strWhere, int rowNumber)
        {
		    strWhere = SQLInjectionFilter(strWhere);
            StringBuilder strSql = new StringBuilder();
			
			strSql.Append("select top ").Append(rowNumber).Append("  [ID],[CustomerID],[服务项目],[产品名称],[编号],[供货商],[品牌],[类别],[型号],[单位],[规格],[数量],[单价],[总价],[具体详情],[负责人],[日期时间],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[SaleType],[AttachmentPath],[跟进信息1],[跟进信息2],[跟进信息3],[跟进信息4],[跟进信息5] from [tb_ProductSale] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where  " + strWhere);
            }
            List<tbProductSaleEntity> list = new List<tbProductSaleEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
				int seq=0;
                while (dataReader.Read())
                {	
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		
		
		
		
		
        /// <summary>
        /// 按主键查询对应的实体
        /// </summary>
        /// <param name="id">主键ID</param>
        /// <returns></returns>
        public override tbProductSaleEntity GetById(int id)
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("select [ID],[CustomerID],[服务项目],[产品名称],[编号],[供货商],[品牌],[类别],[型号],[单位],[规格],[数量],[单价],[总价],[具体详情],[负责人],[日期时间],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[SaleType],[AttachmentPath],[跟进信息1],[跟进信息2],[跟进信息3],[跟进信息4],[跟进信息5] from [tb_ProductSale]  where ID= @ID ");
				
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ID", DbType.Int32, id);
            tbProductSaleEntity entity = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    entity = ReaderBind(dataReader);
                }
            }
            return entity;

        }
		
		
		 /// <summary>
        /// 保存实体
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override int Save()
        {
			
            if (this.ID ==0)
            {
                this.ID = GetMax("tb_ProductSale");
            }
            StringBuilder strSql = new StringBuilder();
			strSql.Append("insert into  tb_ProductSale (");
			strSql.Append("[ID],[CustomerID],[服务项目],[产品名称],[编号],[供货商],[品牌],[类别],[型号],[单位],[规格],[数量],[单价],[总价],[具体详情],[负责人],[日期时间],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[SaleType],[AttachmentPath],[跟进信息1],[跟进信息2],[跟进信息3],[跟进信息4],[跟进信息5] )");
			strSql.Append(" values (");
			strSql.Append("@ID,@CustomerID,@服务项目,@产品名称,@编号,@供货商,@品牌,@类别,@型号,@单位,@规格,@数量,@单价,@总价,@具体详情,@负责人,@日期时间,@CreateDate,@CreateBy,@ModifyDate,@ModifyBy,@SaleType,@AttachmentPath,@跟进信息1,@跟进信息2,@跟进信息3,@跟进信息4,@跟进信息5)");

            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
			db.AddInParameter(dbCommand, "ID", DbType.Int32, this.ID);
			db.AddInParameter(dbCommand, "CustomerID", DbType.Int32, this.CustomerID);
			db.AddInParameter(dbCommand, "服务项目", DbType.String, this.服务项目);
			db.AddInParameter(dbCommand, "产品名称", DbType.String, this.产品名称);
			db.AddInParameter(dbCommand, "编号", DbType.String, this.编号);
			db.AddInParameter(dbCommand, "供货商", DbType.String, this.供货商);
			db.AddInParameter(dbCommand, "品牌", DbType.String, this.品牌);
			db.AddInParameter(dbCommand, "类别", DbType.String, this.类别);
			db.AddInParameter(dbCommand, "型号", DbType.String, this.型号);
			db.AddInParameter(dbCommand, "单位", DbType.String, this.单位);
			db.AddInParameter(dbCommand, "规格", DbType.String, this.规格);
			if (this.数量 == null)
			{
			db.AddInParameter(dbCommand, "数量", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "数量", DbType.Int32, this.数量.Value);
			}
			if (this.单价 == null)
			{
			db.AddInParameter(dbCommand, "单价", DbType.Decimal, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "单价", DbType.Decimal, this.单价.Value);
			}
			if (this.总价 == null)
			{
			db.AddInParameter(dbCommand, "总价", DbType.Decimal, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "总价", DbType.Decimal, this.总价.Value);
			}
			db.AddInParameter(dbCommand, "具体详情", DbType.String, this.具体详情);
			db.AddInParameter(dbCommand, "负责人", DbType.String, this.负责人);
			if (this.日期时间 == null)
			{
			db.AddInParameter(dbCommand, "日期时间", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "日期时间", DbType.DateTime, this.日期时间.Value);
			}
			if (this.CreateDate == null)
			{
			db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, this.CreateDate.Value);
			}
			if (this.CreateBy == null)
			{
			db.AddInParameter(dbCommand, "CreateBy", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "CreateBy", DbType.Int32, this.CreateBy.Value);
			}
			if (this.ModifyDate == null)
			{
			db.AddInParameter(dbCommand, "ModifyDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "ModifyDate", DbType.DateTime, this.ModifyDate.Value);
			}
			if (this.ModifyBy == null)
			{
			db.AddInParameter(dbCommand, "ModifyBy", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "ModifyBy", DbType.Int32, this.ModifyBy.Value);
			}
			db.AddInParameter(dbCommand, "SaleType", DbType.String, this.SaleType);
			db.AddInParameter(dbCommand, "AttachmentPath", DbType.String, this.AttachmentPath);
			db.AddInParameter(dbCommand, "跟进信息1", DbType.String, this.跟进信息1);
			db.AddInParameter(dbCommand, "跟进信息2", DbType.String, this.跟进信息2);
			db.AddInParameter(dbCommand, "跟进信息3", DbType.String, this.跟进信息3);
			db.AddInParameter(dbCommand, "跟进信息4", DbType.String, this.跟进信息4);
			db.AddInParameter(dbCommand, "跟进信息5", DbType.String, this.跟进信息5);

			return db.ExecuteNonQuery(dbCommand);
		  
      
        }
		

		
        /// <summary>
        /// 保存实体
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override int Save(tbProductSaleEntity entity)
        {
			
            if (entity.ID == 0)
            {
                entity.ID = GetMax("tb_ProductSale");
            }
            StringBuilder strSql = new StringBuilder();
			strSql.Append("insert into  tb_ProductSale (");
			strSql.Append("[ID],[CustomerID],[服务项目],[产品名称],[编号],[供货商],[品牌],[类别],[型号],[单位],[规格],[数量],[单价],[总价],[具体详情],[负责人],[日期时间],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[SaleType],[AttachmentPath],[跟进信息1],[跟进信息2],[跟进信息3],[跟进信息4],[跟进信息5] )");
			strSql.Append(" values (");
			strSql.Append("@ID,@CustomerID,@服务项目,@产品名称,@编号,@供货商,@品牌,@类别,@型号,@单位,@规格,@数量,@单价,@总价,@具体详情,@负责人,@日期时间,@CreateDate,@CreateBy,@ModifyDate,@ModifyBy,@SaleType,@AttachmentPath,@跟进信息1,@跟进信息2,@跟进信息3,@跟进信息4,@跟进信息5)");

            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
			db.AddInParameter(dbCommand, "ID", DbType.Int32, entity.ID);
			db.AddInParameter(dbCommand, "CustomerID", DbType.Int32, entity.CustomerID);
			db.AddInParameter(dbCommand, "服务项目", DbType.String, entity.服务项目);
			db.AddInParameter(dbCommand, "产品名称", DbType.String, entity.产品名称);
			db.AddInParameter(dbCommand, "编号", DbType.String, entity.编号);
			db.AddInParameter(dbCommand, "供货商", DbType.String, entity.供货商);
			db.AddInParameter(dbCommand, "品牌", DbType.String, entity.品牌);
			db.AddInParameter(dbCommand, "类别", DbType.String, entity.类别);
			db.AddInParameter(dbCommand, "型号", DbType.String, entity.型号);
			db.AddInParameter(dbCommand, "单位", DbType.String, entity.单位);
			db.AddInParameter(dbCommand, "规格", DbType.String, entity.规格);
			if (entity.数量 == null)
			{
			db.AddInParameter(dbCommand, "数量", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "数量", DbType.Int32, entity.数量.Value);
			}
			if (entity.单价 == null)
			{
			db.AddInParameter(dbCommand, "单价", DbType.Decimal, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "单价", DbType.Decimal, entity.单价.Value);
			}
			if (entity.总价 == null)
			{
			db.AddInParameter(dbCommand, "总价", DbType.Decimal, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "总价", DbType.Decimal, entity.总价.Value);
			}
			db.AddInParameter(dbCommand, "具体详情", DbType.String, entity.具体详情);
			db.AddInParameter(dbCommand, "负责人", DbType.String, entity.负责人);
			if (entity.日期时间 == null)
			{
			db.AddInParameter(dbCommand, "日期时间", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "日期时间", DbType.DateTime, entity.日期时间.Value);
			}
			if (entity.CreateDate == null)
			{
			db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, entity.CreateDate.Value);
			}
			if (entity.CreateBy == null)
			{
			db.AddInParameter(dbCommand, "CreateBy", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "CreateBy", DbType.Int32, entity.CreateBy.Value);
			}
			if (entity.ModifyDate == null)
			{
			db.AddInParameter(dbCommand, "ModifyDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "ModifyDate", DbType.DateTime, entity.ModifyDate.Value);
			}
			if (entity.ModifyBy == null)
			{
			db.AddInParameter(dbCommand, "ModifyBy", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "ModifyBy", DbType.Int32, entity.ModifyBy.Value);
			}
			db.AddInParameter(dbCommand, "SaleType", DbType.String, entity.SaleType);
			db.AddInParameter(dbCommand, "AttachmentPath", DbType.String, entity.AttachmentPath);
			db.AddInParameter(dbCommand, "跟进信息1", DbType.String, entity.跟进信息1);
			db.AddInParameter(dbCommand, "跟进信息2", DbType.String, entity.跟进信息2);
			db.AddInParameter(dbCommand, "跟进信息3", DbType.String, entity.跟进信息3);
			db.AddInParameter(dbCommand, "跟进信息4", DbType.String, entity.跟进信息4);
			db.AddInParameter(dbCommand, "跟进信息5", DbType.String, entity.跟进信息5);

			return db.ExecuteNonQuery(dbCommand);
		  
      
        }
		
		
        /// <summary>
        /// 保存或者更新(如果传入的实体主键为空则保存,否则做更新操作)
        /// </summary>
        /// <param name="entity">传入的实体</param>
        /// <returns>影响的行数</returns>
        public override int SaveOrUpdate(tbProductSaleEntity entity)
        {
			
            if (entity.ID  == 0)
            {
                if (Save(entity)>0)
                {
                    return 1;
                }
                else
                {
                    return 0;
                }
            }
            else
            {
                return Update(entity);
            }
        }
		
		/// <summary>
        /// 保存或者更新(如果传入的实体主键为空则保存,否则做更新操作)
        /// </summary>
        /// <param name="entity">传入的实体</param>
        /// <returns>影响的行数</returns>
        public override int SaveOrUpdate()
        {
		
            if (this.ID  == 0)
            {
                if (Save()>0)
                {
                    return 1;
                }
                else
                {
                    return 0;
                }
            }
            else
            {
                return Update();
            }
        }
		
		/// <summary>
        /// 是否存在对应主键ID的记录
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public override bool IsExist(int ID)
        {
            Database db = GetDatabase();
            StringBuilder strSql = new StringBuilder();
            			 strSql.Append("select count(1) from tb_ProductSale where ID=@ID ");

            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ID", DbType.Int32, ID);//这里为ID是因为原有代码把主键都变成了ID.
            int cmdresult;
            object obj = db.ExecuteScalar(dbCommand);
            if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
            {
                cmdresult = 0;
            }
            else
            {
                cmdresult = int.Parse(obj.ToString());
            }
            if (cmdresult == 0)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
		
		
		/// <summary>
        /// 删除对应的实体
        /// </summary>
        /// <param name="entity"></param>
        public override int Delete(tbProductSaleEntity entity)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete tb_ProductSale ");
            strSql.Append(" where ID=@ID ");
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ID", DbType.Int32, entity.ID );
            return db.ExecuteNonQuery(dbCommand);
        }
		
		/// <summary>
        /// 删除主键ID对应的记录
        /// </summary>
        /// <param name="id"></param>
        public override int Delete(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete tb_ProductSale ");
            strSql.Append(" where ID=@ID ");
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ID", DbType.Int32, id);
            return db.ExecuteNonQuery(dbCommand);
        }
		
		
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public override int Update()
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update tb_ProductSale set ");
			strSql.Append("[ID]=@ID,[CustomerID]=@CustomerID,[服务项目]=@服务项目,[产品名称]=@产品名称,[编号]=@编号,[供货商]=@供货商,[品牌]=@品牌,[类别]=@类别,[型号]=@型号,[单位]=@单位,[规格]=@规格,[数量]=@数量,[单价]=@单价,[总价]=@总价,[具体详情]=@具体详情,[负责人]=@负责人,[日期时间]=@日期时间,[CreateDate]=@CreateDate,[CreateBy]=@CreateBy,[ModifyDate]=@ModifyDate,[ModifyBy]=@ModifyBy,[SaleType]=@SaleType,[AttachmentPath]=@AttachmentPath,[跟进信息1]=@跟进信息1,[跟进信息2]=@跟进信息2,[跟进信息3]=@跟进信息3,[跟进信息4]=@跟进信息4,[跟进信息5]=@跟进信息5 ");

            strSql.Append(" where ID=@ID ");
            Database db = GetDatabase();
			DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
			db.AddInParameter(dbCommand, "ID", DbType.Int32, this.ID );
			db.AddInParameter(dbCommand, "CustomerID", DbType.Int32, this.CustomerID);
			db.AddInParameter(dbCommand, "服务项目", DbType.String, this.服务项目);
			db.AddInParameter(dbCommand, "产品名称", DbType.String, this.产品名称);
			db.AddInParameter(dbCommand, "编号", DbType.String, this.编号);
			db.AddInParameter(dbCommand, "供货商", DbType.String, this.供货商);
			db.AddInParameter(dbCommand, "品牌", DbType.String, this.品牌);
			db.AddInParameter(dbCommand, "类别", DbType.String, this.类别);
			db.AddInParameter(dbCommand, "型号", DbType.String, this.型号);
			db.AddInParameter(dbCommand, "单位", DbType.String, this.单位);
			db.AddInParameter(dbCommand, "规格", DbType.String, this.规格);
			if (this.数量 == null)
			{
			db.AddInParameter(dbCommand, "数量", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "数量", DbType.Int32, this.数量.Value);
			}
			if (this.单价 == null)
			{
			db.AddInParameter(dbCommand, "单价", DbType.Decimal, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "单价", DbType.Decimal, this.单价.Value);
			}
			if (this.总价 == null)
			{
			db.AddInParameter(dbCommand, "总价", DbType.Decimal, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "总价", DbType.Decimal, this.总价.Value);
			}
			db.AddInParameter(dbCommand, "具体详情", DbType.String, this.具体详情);
			db.AddInParameter(dbCommand, "负责人", DbType.String, this.负责人);
			if (this.日期时间 == null)
			{
			db.AddInParameter(dbCommand, "日期时间", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "日期时间", DbType.DateTime, this.日期时间.Value);
			}
			if (this.CreateDate == null)
			{
			db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, this.CreateDate.Value);
			}
			if (this.CreateBy == null)
			{
			db.AddInParameter(dbCommand, "CreateBy", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "CreateBy", DbType.Int32, this.CreateBy.Value);
			}
			if (this.ModifyDate == null)
			{
			db.AddInParameter(dbCommand, "ModifyDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "ModifyDate", DbType.DateTime, this.ModifyDate.Value);
			}
			if (this.ModifyBy == null)
			{
			db.AddInParameter(dbCommand, "ModifyBy", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "ModifyBy", DbType.Int32, this.ModifyBy.Value);
			}
			db.AddInParameter(dbCommand, "SaleType", DbType.String, this.SaleType);
			db.AddInParameter(dbCommand, "AttachmentPath", DbType.String, this.AttachmentPath);
			db.AddInParameter(dbCommand, "跟进信息1", DbType.String, this.跟进信息1);
			db.AddInParameter(dbCommand, "跟进信息2", DbType.String, this.跟进信息2);
			db.AddInParameter(dbCommand, "跟进信息3", DbType.String, this.跟进信息3);
			db.AddInParameter(dbCommand, "跟进信息4", DbType.String, this.跟进信息4);
			db.AddInParameter(dbCommand, "跟进信息5", DbType.String, this.跟进信息5);

			
			return	db.ExecuteNonQuery(dbCommand);

		}
		



		
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public override int Update(tbProductSaleEntity entity)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update tb_ProductSale set ");
			strSql.Append("[ID]=@ID,[CustomerID]=@CustomerID,[服务项目]=@服务项目,[产品名称]=@产品名称,[编号]=@编号,[供货商]=@供货商,[品牌]=@品牌,[类别]=@类别,[型号]=@型号,[单位]=@单位,[规格]=@规格,[数量]=@数量,[单价]=@单价,[总价]=@总价,[具体详情]=@具体详情,[负责人]=@负责人,[日期时间]=@日期时间,[CreateDate]=@CreateDate,[CreateBy]=@CreateBy,[ModifyDate]=@ModifyDate,[ModifyBy]=@ModifyBy,[SaleType]=@SaleType,[AttachmentPath]=@AttachmentPath,[跟进信息1]=@跟进信息1,[跟进信息2]=@跟进信息2,[跟进信息3]=@跟进信息3,[跟进信息4]=@跟进信息4,[跟进信息5]=@跟进信息5 ");

            strSql.Append(" where ID=@ID ");
            Database db = GetDatabase();
			DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
			db.AddInParameter(dbCommand, "ID", DbType.Int32, entity.ID );
			db.AddInParameter(dbCommand, "CustomerID", DbType.Int32, entity.CustomerID);
			db.AddInParameter(dbCommand, "服务项目", DbType.String, entity.服务项目);
			db.AddInParameter(dbCommand, "产品名称", DbType.String, entity.产品名称);
			db.AddInParameter(dbCommand, "编号", DbType.String, entity.编号);
			db.AddInParameter(dbCommand, "供货商", DbType.String, entity.供货商);
			db.AddInParameter(dbCommand, "品牌", DbType.String, entity.品牌);
			db.AddInParameter(dbCommand, "类别", DbType.String, entity.类别);
			db.AddInParameter(dbCommand, "型号", DbType.String, entity.型号);
			db.AddInParameter(dbCommand, "单位", DbType.String, entity.单位);
			db.AddInParameter(dbCommand, "规格", DbType.String, entity.规格);
			if (entity.数量 == null)
			{
			db.AddInParameter(dbCommand, "数量", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "数量", DbType.Int32, entity.数量.Value);
			}
			if (entity.单价 == null)
			{
			db.AddInParameter(dbCommand, "单价", DbType.Decimal, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "单价", DbType.Decimal, entity.单价.Value);
			}
			if (entity.总价 == null)
			{
			db.AddInParameter(dbCommand, "总价", DbType.Decimal, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "总价", DbType.Decimal, entity.总价.Value);
			}
			db.AddInParameter(dbCommand, "具体详情", DbType.String, entity.具体详情);
			db.AddInParameter(dbCommand, "负责人", DbType.String, entity.负责人);
			if (entity.日期时间 == null)
			{
			db.AddInParameter(dbCommand, "日期时间", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "日期时间", DbType.DateTime, entity.日期时间.Value);
			}
			if (entity.CreateDate == null)
			{
			db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, entity.CreateDate.Value);
			}
			if (entity.CreateBy == null)
			{
			db.AddInParameter(dbCommand, "CreateBy", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "CreateBy", DbType.Int32, entity.CreateBy.Value);
			}
			if (entity.ModifyDate == null)
			{
			db.AddInParameter(dbCommand, "ModifyDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "ModifyDate", DbType.DateTime, entity.ModifyDate.Value);
			}
			if (entity.ModifyBy == null)
			{
			db.AddInParameter(dbCommand, "ModifyBy", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "ModifyBy", DbType.Int32, entity.ModifyBy.Value);
			}
			db.AddInParameter(dbCommand, "SaleType", DbType.String, entity.SaleType);
			db.AddInParameter(dbCommand, "AttachmentPath", DbType.String, entity.AttachmentPath);
			db.AddInParameter(dbCommand, "跟进信息1", DbType.String, entity.跟进信息1);
			db.AddInParameter(dbCommand, "跟进信息2", DbType.String, entity.跟进信息2);
			db.AddInParameter(dbCommand, "跟进信息3", DbType.String, entity.跟进信息3);
			db.AddInParameter(dbCommand, "跟进信息4", DbType.String, entity.跟进信息4);
			db.AddInParameter(dbCommand, "跟进信息5", DbType.String, entity.跟进信息5);

			
			return	db.ExecuteNonQuery(dbCommand);

		}
		


		
		
		
		
		/// <summary>
        /// 对象实体绑定数据
		///生成构造为list的构造器
        /// </summary>
        private tbProductSaleEntity ReaderBind(IDataReader dataReader,int seq)
        {
            ITOMMS.Entity.tbProductSaleEntity entity = new ITOMMS.Entity.tbProductSaleEntity();
			entity.SEQNO = seq;
            object obj;
			obj = dataReader["ID"];
			 if (obj != null && obj != DBNull.Value)
			 {
			 entity.ID = (int)obj;
			 }
			 obj=dataReader["CustomerID"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.CustomerID= (int)obj;
			}
			 entity.服务项目= dataReader["服务项目"].ToString();
			 entity.产品名称= dataReader["产品名称"].ToString();
			 entity.编号= dataReader["编号"].ToString();
			 entity.供货商= dataReader["供货商"].ToString();
			 entity.品牌= dataReader["品牌"].ToString();
			 entity.类别= dataReader["类别"].ToString();
			 entity.型号= dataReader["型号"].ToString();
			 entity.单位= dataReader["单位"].ToString();
			 entity.规格= dataReader["规格"].ToString();
			 obj=dataReader["数量"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.数量= (int)obj;
			}
			 obj=dataReader["单价"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.单价= (decimal)obj;
			}
			 obj=dataReader["总价"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.总价= (decimal)obj;
			}
			 entity.具体详情= dataReader["具体详情"].ToString();
			 entity.负责人= dataReader["负责人"].ToString();
			 obj=dataReader["日期时间"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.日期时间= (DateTime)obj;
			}
			 obj=dataReader["CreateDate"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.CreateDate= (DateTime)obj;
			}
			 obj=dataReader["CreateBy"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.CreateBy= (int)obj;
			}
			 obj=dataReader["ModifyDate"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ModifyDate= (DateTime)obj;
			}
			 obj=dataReader["ModifyBy"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ModifyBy= (int)obj;
			}
			 entity.SaleType= dataReader["SaleType"].ToString();
			 entity.AttachmentPath= dataReader["AttachmentPath"].ToString();
			 entity.跟进信息1= dataReader["跟进信息1"].ToString();
			 entity.跟进信息2= dataReader["跟进信息2"].ToString();
			 entity.跟进信息3= dataReader["跟进信息3"].ToString();
			 entity.跟进信息4= dataReader["跟进信息4"].ToString();
			 entity.跟进信息5= dataReader["跟进信息5"].ToString();

            return entity;
        }
		
		
				/// <summary>
        /// 对象实体绑定数据
		///生成构造为list的构造器
        /// </summary>
        private tbProductSaleEntity ReaderBind(IDataReader dataReader)
        {
            ITOMMS.Entity.tbProductSaleEntity entity = new ITOMMS.Entity.tbProductSaleEntity();
			object obj;
			obj = dataReader["ID"];
			 if (obj != null && obj != DBNull.Value)
			 {
			 entity.ID = (int)obj;
			 }
			 obj=dataReader["CustomerID"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.CustomerID= (int)obj;
			}
			 entity.服务项目= dataReader["服务项目"].ToString();
			 entity.产品名称= dataReader["产品名称"].ToString();
			 entity.编号= dataReader["编号"].ToString();
			 entity.供货商= dataReader["供货商"].ToString();
			 entity.品牌= dataReader["品牌"].ToString();
			 entity.类别= dataReader["类别"].ToString();
			 entity.型号= dataReader["型号"].ToString();
			 entity.单位= dataReader["单位"].ToString();
			 entity.规格= dataReader["规格"].ToString();
			 obj=dataReader["数量"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.数量= (int)obj;
			}
			 obj=dataReader["单价"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.单价= (decimal)obj;
			}
			 obj=dataReader["总价"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.总价= (decimal)obj;
			}
			 entity.具体详情= dataReader["具体详情"].ToString();
			 entity.负责人= dataReader["负责人"].ToString();
			 obj=dataReader["日期时间"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.日期时间= (DateTime)obj;
			}
			 obj=dataReader["CreateDate"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.CreateDate= (DateTime)obj;
			}
			 obj=dataReader["CreateBy"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.CreateBy= (int)obj;
			}
			 obj=dataReader["ModifyDate"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ModifyDate= (DateTime)obj;
			}
			 obj=dataReader["ModifyBy"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ModifyBy= (int)obj;
			}
			 entity.SaleType= dataReader["SaleType"].ToString();
			 entity.AttachmentPath= dataReader["AttachmentPath"].ToString();
			 entity.跟进信息1= dataReader["跟进信息1"].ToString();
			 entity.跟进信息2= dataReader["跟进信息2"].ToString();
			 entity.跟进信息3= dataReader["跟进信息3"].ToString();
			 entity.跟进信息4= dataReader["跟进信息4"].ToString();
			 entity.跟进信息5= dataReader["跟进信息5"].ToString();

            return entity;
        }
		
		
		
		 #endregion
		
	}
}
